/////////////////////////////////////////////////////////////////////////////////////////////
// Filename: GameTimer.h
//
// The GameTimer ticks every frame and can be querried for time data. GameTimer is not 
// updated during the OS message pump. 
// GameTimer is the only subsystem that does not have a state machine.
//
// (c) Dave Ottley, 2012. All rights reserved.
/////////////////////////////////////////////////////////////////////////////////////////////
#ifndef GAMETIMER_H
#define GAMETIMER_H

///////////////////////////
//		INCLUDES
///////////////////////////


///////////////////////////
//		MY INCLUDES
///////////////////////////



///////////////////////////
//   GAME TIMER CLASS
///////////////////////////
class GameTimer
{
private:
	//SINGLETON
	GameTimer();
	~GameTimer();
	GameTimer(const GameTimer&);
	GameTimer& operator=(const GameTimer& rhs);

public:
	static GameTimer * GetInstance();

public:
	double TotalUnpausedTime()const;	// in seconds
	double TotalTime() const { return (mCurrTime - mBaseTime); }
	double DeltaTime()const { return mDeltaTime; }			

	void Reset(); // Call before message loop.
	void Start(); // Call when unpaused.
	void Stop();  // Call when paused.
	void Tick();  // Call every frame.

	virtual bool HandleMessage(const Telegram& msg);

private:
	double mSecondsPerCount;
	double mDeltaTime;

	__int64 mBaseTime;
	__int64 mPausedTime;
	__int64 mStopTime;
	__int64 mPrevTime;
	__int64 mCurrTime;

	bool mStopped;
	uint32_t mID;
};

#ifndef GTimer
#define GTimer GameTimer::GetInstance()
#endif

#endif // GAMETIMER_H